/*
 * Copyright 2020 tu.cn All right reserved. This software is the
 * confidential and proprietary information of tu.cn ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Tu.cn
 */
package com.onedec.utils;

import com.onedec.exception.NoAccessException;
import com.onedec.exception.ParamException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 31014
 * @date 2020/7/9 16:58
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = NoAccessException.class)
    @ResponseBody
    public ResponseEntity<Void> noAccessException(NoAccessException noAccessException) throws Exception {
        final ResponseEntity<Void> responseEntity = new ResponseEntity<>("无访问权限", "A-100");
        return responseEntity;
    }
    @ExceptionHandler(value = NoAccessException.class)
    @ResponseBody
    public ResponseEntity<Void> paramException(ParamException paramException) throws Exception {
        final ResponseEntity<Void> responseEntity = new ResponseEntity<>("参数异常", "P-100");
        return responseEntity;
    }
}